<template>
    <div class="song">
        <div class="top">
            <div class="box" >
                <div class="moboli" :style="{
                backgroundImage:'url('+songsname.coverImgUrl+')'
            }"></div>
                <img :src="songsname.coverImgUrl" alt="">
                <div>
                    <div class="songlist">精品歌单</div>
                    <div class="name">{{songsname.name}}</div>
                </div>   
            </div>
        </div>
        <div class="bottom">
            <div class="bott">
                <div class="ltem">
                    <div class="ltemname">{{cat}}
                        <i class="el-icon-arrow-right"></i>
                    </div>
                    <div class="itemright">
                        <div :class="{caticv:currindex === index}" @click="tagcilck(item.name,index)" v-for="(item,index) in lotsonglist" :key='item.id'>{{item.name}}</div>
                    </div>
                </div>
                
                <div class="resonglistlist">
                    <div @click="songlistdata(item.id)" class="imglist"  v-for="(item,index) in resonglist" :key = 'item.id'>
                        <img @mouseover='fnshow(index)' @mouseout='hide' :src="item.coverImgUrl" alt="">
                        <div>{{item.name}}</div>
                        <div @mouseover='fnshow(index)' class="imgiii" :class="{active: index === show}">
                            <i class="el-icon-video-play"></i>
                        </div>
                        <div class="playcount">
                            <i class="el-icon-video-play"></i>
                        {{mill(item.playCount)}}</div>
                    </div>
                </div>
                <el-pagination
                @current-change = 'change'

                :current-page ='page'
                :page-size = '30'
                background
                layout="prev, pager, next"
                :total="total">
                </el-pagination>
            </div>
            
            
        </div>

    </div>
</template>

<script>
import http from '@/http/http.js'
import million from '@/unit/numberhalden.js'  //数字过万处理

export default {
    data() {
        return {
            cat:'华语',
            currindex:0,
            lotsonglist:[],
            songsname:[],
            resonglist:[],
            show:100,
            total:null,
            page:1,
            pages:0

        }
    },
    methods: {

        

        tagcilck(tah,index){
            this.page = 1
            console.log(this.page)
            this.cat = tah
            this.currindex = index
            http({
            url:'/top/playlist',
            params:{
                cat:this.cat,
                limit:30
            }
            }).then(res=>{
                // console.log(res.data.playlists)
                this.resonglist = res.data.playlists
            })

            http({
            url:'/top/playlist/highquality',
            params:{
                limit:1,
                cat:this.cat
            }
            }).then(res=>{
                // console.log(res)
                this.songsname = res.data.playlists[0] 
            })
            this.pageshane()

        },
        change(value){
            // console.log(value)
            this.page = value
            http({
            url:'/top/playlist',
            params:{
                cat:this.cat,
                offset:(this.page-1)*30
            }
            }).then(res=>{
                console.log(res.data)
                this.resonglist = res.data.playlists
                this.total = res.data.total
            })
        },
        

        mill(value){
             return million(value)
        },

        songlistdata(id){
            console.log(id)
            this.$router.push({
                name:'songlistid',
                params:{
                    id
                }
            })
            
        },

        fnshow(index){
            // console.log(index)
            this.show = index
        },
        hide(){
            this.show = 100
        }
    },
    mounted() {
        http({
            url:'/playlist/hot'
        }).then(res=>{
            // console.log(res)
            this.lotsonglist = res.data.tags
        })

        http({
            url:'/top/playlist',
            params:{
                cat:this.cat,
                limit:30

            }
        }).then(res=>{
            console.log(res.data)
            this.resonglist = res.data.playlists
            this.total = res.data.total
        })

        http({
            url:'/top/playlist/highquality',
            params:{
                limit:1,
                cat:this.cat
            }
        }).then(res=>{
            // console.log(res)
            this.songsname = res.data.playlists[0] 
            // this.total = res.data.playlists[0].total
        })
    },
}
</script>

<style lang="less" scoped>

.caticv{
    color: pink;
}
        
.bott{

}
   

.bottom{
    width: 80%;
    text-align: center;
    display: flex;
    margin-top: 30px;
    margin: 0 auto;
    margin-bottom: 30px;
    // justify-content: center;
    // margin-left: 200px;
    .ltem{
        width: 1300px;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        cursor: pointer;
        margin: 10px 0;
        .ltemname{
            border: 1px solid #666;
            border-radius: 20px;
            font-size: 12px;
            padding: 6px;
            padding-left: 10px;
            text-align: center;
        }
        .ltemname:hover{
            background-color: #f3f3f3;
        }
        .itemright{
            display: flex;
            flex-direction: row;
            font-size: 12px;
            div{
                margin-left: 5px;
                cursor: pointer;
            };
        }
    }
    .resonglistlist{
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: space-between;
            .imglist{     
                width: 250px;
                height: 250px;
                padding-bottom: 50px;
                // border-radius: 10px;
                // overflow: hidden;
                position: relative;
                img{
                    width: 100%;
                    height: 100%;
                    border-radius: 10px;

                    
                }
                .imgiii{
                    display: none;
                    position: absolute;
                    font-size: 40px;
                    color: pink;
                    right: 20px;
                    bottom: 60px;
                }
                .playcount{
                    
                    position: absolute;
                    font-size: 12px;
                    
                    color: white;
                    right: 20px;
                    top: 10px;
                    
                }
                .active{
                    display: block;
                }
            }
        }
.resonglistlist:hover{
    cursor: pointer;
    
}
}
.song{
    width: 100%;
    min-width: 1200px;
    margin: 0 auto;

    
}
.top{
    display: flex;
    justify-content: center;
}
.moboli{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: blur(30px);
    transform: scale(1.2);
    z-index: -1;
}
.box{
    position: relative;
    display: flex;
    flex-direction: row;
    // justify-content: center;
    // border: 1px solid red;
    width: 1350px;
    height: 180px;
    background-size: cover;
    background-position: center;
    overflow: hidden;
    border-radius: 5px;
    // filter: blur(10px);

    img{
        width: 130px;
        height: 130px;
        margin: 20px;
    }
    .songlist{
        width: 100px;
        height: 30px;
        line-height: 30px;
        border-radius: 30px;
        margin-top: 20px;
        text-align: center;
        border: 1px solid peru;

        color: peru;
    }
    .name{
        color: white;
        margin-top: 10px;
    }
}
</style>